# Contributor: Clayton Craft <clayton@craftyguy.net>
# Contributor: Thomas Böhler <witcher@wiredspace.de>
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=goimapnotify
pkgver=2.4
pkgrel=0
pkgdesc="execute scripts on IMAP mailbox changes using IDLE, golang version"
url="https://gitlab.com/shackra/goimapnotify"
arch="all"
license="GPL-3.0-or-later"
makedepends="go"
options="net"
source="https://gitlab.com/shackra/goimapnotify/-/archive/$pkgver/goimapnotify-$pkgver.tar.gz"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	export CGO_CPPFLAGS="$CPPFLAGS"
	export CGO_CFLAGS="$CFLAGS"
	export CGO_CXXFLAGS="$CXXFLAGS"
	export CGO_LDFLAGS="$LDFLAGS"
	export GOFLAGS="$GOFLAGS -trimpath -mod=readonly -modcacherw"

	go build -ldflags "-linkmode=external \"-extldflags=$LDFLAGS\""
}

check() {
	go test ./...
}

package() {
	install -Dm755 goimapnotify "$pkgdir"/usr/bin/goimapnotify
	install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE
	install -Dm644 README.md "$pkgdir"/usr/share/doc/"$pkgname"/README.md
	install -Dm644 CHANGELOG.md "$pkgdir"/usr/share/doc/"$pkgname"/CHANGELOG.md
}

sha512sums="
cda7ad81239fce7930b5a4c64728d09791f65061ce5570cd9f3c4c2640eb46ea912ec0c6349cfdf5355f77667357c05f0b194563c370f3296b65a5881e047d15  goimapnotify-2.4.tar.gz
"
